﻿using SqlSugar;
using Hiver.Entity;
using Hiver.Util.Helper;
using Hiver.Util.SqlServer.SqlSugar;

namespace Hiver.Data.Impl
{
    /// <summary>
    /// 用户仓库实现类
    /// </summary>
    public class UserRepository : IUserRepository
    {
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public UserInfo Login(string userName, string password)
        {
            using(SqlSugarClient db = SqlSugarConn.GetInstance())
            {
                UserInfo user = db.Queryable<UserInfo>().Where(c => c.UserNo.Equals(userName) && c.Password.Equals(SecurityHelper.MD5(password)) && c.Del == false).Single();
                return user;
            }
        }
    }
}